#include "Level.h"

Level::Level(void)
{
}

Level::~Level(void)
{
}

void Level::draw(){
    // Draws Camera
    // Camera Position, Direction, and upVector
    gluLookAt(
        activeCamera->position.x,
        activeCamera->position.y,
        activeCamera->position.z,

        activeCamera->pointOfFocus.x,
        activeCamera->pointOfFocus.y,
        activeCamera->pointOfFocus.z,

        activeCamera->up.x,
        activeCamera->up.y,
        activeCamera->up.z);

    // Draw Objects
    if(objectList.size() > 0)
    {
        std::vector<Objects *>::iterator it;
        for(it = objectList.begin(); it != objectList.end(); it++)
        {
            Objects *e = (*it);
            e->draw();
            //e->drawVertices();
        }
    }
}
void Level::init(){
    camera1 = new Camera();
    cameraList.push_back(camera1);

    camera1->mode = CAM_FREE;

    camera1->SetPosition(Vector3f(0,1,5));

    activeCamera = camera1;
}

void Level::update(){
    /* gameplay for the level */

    /* Update all the Objects */
    if(objectList.size() > 0)
    {
        std::vector<Objects *>::iterator it;
        for(it = objectList.begin(); it != objectList.end(); it++)
        {
            Objects *e = (*it);
            e->update(); // <-- Collisions in here!
        }
    }
}

void Level::setActiveCamera(int id)
{
    if(id >= 0 && id < cameraList.size())
    {
        activeCamera = cameraList[id];
    }
}

void LevelOne::init(){
    // Level Initialization
    Level::init();

    // Add Cameras
    OvrCam = new Camera();
    cameraList.push_back(OvrCam);
    FPSCam = new Camera();
    cameraList.push_back(FPSCam);
    /*
    FlwCam = new Camera();
    cameraList.push_back(FlwCam);*/

    OvrCam->mode = CAM_OVR;
    FPSCam->mode = CAM_FPS;/*
    FlwCam->mode = CAM_FLW;*/

    OvrCam->SetPosition(Vector3f(0,20,5));
    FPSCam->SetPosition(Vector3f(2,1,2));/*
    FlwCam->SetPosition(Vector3f(0,10,20));*/
    
    // Add Objects

    /* PLAYER */
    playerOne = new Player("Objects\\EarthMoon.obj", Vector3f(0,10,15), 0.3);
    objectList.push_back(playerOne);
    cameraList.push_back(playerOne->FlwCam);

    /* MAP */
    map = new Objects("Objects\\HokumTex.obj");
    objectList.push_back(map);

    /* MOBS */
    baseMonster = new Monster("Objects\\Rectangle.obj", Vector3f(5,1,10));

    for(unsigned int amt = 0; amt < MON1; amt++){
        // Creates List of Monsters
        //objectList.push_back(C);
    }
}